﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcMusicStore.Models;

namespace MvcMusicStore.Controllers
{
    public class StoreController : Controller
    {
        //
        // GET: /Store/
        MusicStoreEntities storeDB = new MusicStoreEntities();

        public ActionResult Index()
        {
            var listOfGenre = storeDB.Genres.ToList();
            return View(listOfGenre);
        }

        public ActionResult Browse(string genre)
        {
            var genreModel = storeDB.Genres.Include("Albums").Single(g => g.Name == genre);
            return View(genreModel);
        }

        public ActionResult Details(int? id)
        {
            if (id == (int?)null)
            {
                id = 1000;
            }
            var anbum = storeDB.Albums.FirstOrDefault(s => s.AlbumId == id);
            return View(anbum);
        }

    }
}
